package com.imooc.hadoop.mapreduce.sort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @program: hadoop_db
 * @description: SortMapper
 * @author: zengchen
 * @create: 2021-03-28 21:16
 **/
public class SortMapper extends Mapper<LongWritable, Text, SortWritable, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] nums = value.toString().split("\t");
        if(nums.length > 1){
            context.write(new SortWritable(Long.valueOf(nums[0]), Long.valueOf(nums[1])),
                    NullWritable.get());
        }
    }
}
